Fix incorrect handling of line-height CSS in HTML → PDF conversion #1427
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    



Description of the new Feature/Bugfix
When parsing HTML with a span styled with line-height (e.g., <span "line-height:115%">), the generated Paragraph in OpenPDF 1.3.x computed the multiplied leading incorrectly, resulting in overlapping lines (see attached PDF file).
Expected behavior:
For font size 12pt and line-height:115%, the total leading should be ≈ 13.8pt (12 × 1.15).
Cause:
FactoryProperties.insertStyle, line 383 handles line-height in percentage (by dividing by 100) although the percentage handling is done already inMarkup.parseLength(String string, float actualFontSize), line 553.The problem was most likely introduced by: #1059 When converting HTML to PDF, font size specified in % is interpreted as pixels
Solution:
Adjusted
FactoryProperties.insertStyle- removed handling line-height in percentage.Added a JUnit test (
testLineHeightPercentage) that parses a small HTML snippet with line-height:115% and asserts thatParagraph.getTotalLeading()matches the expected value.Unit-Tests for the Bugfix
Compatibilities Issues
None
Your real name
Radek Wikturna
Testing details
Any other details about how to test the new feature or bugfix?
Line Height Percentage.pdf